package org.qhhc.thread.endthread;

public class StopMethodTest extends Thread{
    @Override
    public void run() {
        while (true){
            System.out.println("Thread is running...");
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){
               Thread.currentThread().interrupt();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        StopMethodTest test = new StopMethodTest();
        test.start();

        // 让线程运行一段时间
        Thread.sleep(5000);

        // 强行让线程终止，不推荐 stop已经没了
        test.interrupt();
    }
}
